#Figure A.6

#directory
#set working directory to the path PvP_Replication
#setwd("~/PvP_Replication")

#libraries
library(sf) #working with spatial data
library(tidyverse) #manipulating data and plotting

#read in military base spatial data
milbase_points <- sf::st_read("PvP_data/military_base_shapefile/milbase_all.shp")

#categorize bases
milbase_points <- milbase_points %>% mutate(basetype = case_when(
  str_detect(layer, "Navy") ~ "Naval", 
  str_detect(layer, "Airforce") ~ "Air", 
  str_detect(layer, "armybase") ~ "Infantry", 
  TRUE ~ "NA"
))

#read in basemap of Colombia
col_borders <- sf::st_read("PvP_gis_figures/FiguresA3-A4/gadm_borders.shp")

#generate map
milbase_map <- ggplot() +
  geom_sf(data = col_borders, fill = "#E0E0E0", color = NA) +
  geom_sf(data = milbase_points, aes(color = basetype, shape = basetype), size = 0.75) +
  scale_shape_manual(values = c("Naval" = 16, "Air" =  17, "Infantry" = 15)) +  
  scale_color_manual(values = c("Naval" = "#0072B2", "Air" =  "#D55E00" , "Infantry" = "#009E73")) +  
  labs(title = "",
       color = "Base Type",
       shape = "Base Type") +
  theme_void() +
  theme(legend.position = "bottom")

#save map
ggsave(plot = milbase_map, filename="PvP_plots/milbase_map.pdf", width = 8,
       height = 6, units = "in")
